package com.yuji.aacar.controller.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yuji.aacar.R;
import com.yuji.aacar.bean.beans.Room;
import com.yuji.aacar.widgets.textview.PingFangTextView;

import java.util.List;


/**
 * <li>Package:com.yuji.aacar.controller.adapter</li>
 * <li>Author: lining </li>
 * <li>Date: 2018/3/2</li>
 * <li>Description:   </li>
 */

public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder> {

    protected Context mContext;
    protected List<Room> mDatas;
    protected LayoutInflater mInflater;

    public RoomAdapter(Context mContext, List<Room> mDatas) {
        this.mContext = mContext;
        this.mDatas = mDatas;
        mInflater = LayoutInflater.from(mContext);
    }

    public List<Room> getDatas() {
        return mDatas;
    }

    public RoomAdapter setDatas(List<Room> datas) {
        mDatas = datas;
        return this;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(mInflater.inflate(R.layout.activity_room_item, parent, false));
    }

    @Override
    public void onBindViewHolder(RoomAdapter.ViewHolder holder, int position) {
        Room cityBean = mDatas.get(position);
        holder.carName.setText(cityBean.getRoomName());
    }

    @Override
    public int getItemCount() {
        return mDatas != null ? mDatas.size() : 0;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        PingFangTextView carName;

        public ViewHolder(View itemView) {
            super(itemView);
            carName = (PingFangTextView) itemView.findViewById(R.id.room_name);
        }
    }
}
